package com.uplift.mobile.info.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.uplift.common.result.IResultable;
import com.uplift.common.result.ResultWrapper;
import com.uplift.common.result.ResultWrapper4Layui;
import com.uplift.mobile.info.model.Info;
import com.uplift.mobile.info.service.IInfoService;

/**
 * 资讯相关
 * 
 * @author bcwang
 *
 */
@Controller
@RequestMapping(value = "/info")
public class InfoController {

	@Autowired
	private IInfoService infoService;

	/**
	 * 查询资讯列表
	 * 
	 * @param user
	 * @return IResultable
	 */
	@RequestMapping(value = "/list")
	@ResponseBody
	public IResultable list(HttpServletRequest request, Info info) {
		try {
			List<Map<String, Object>> list = this.infoService.queryInfo(info);
			return ResultWrapper.wrapListPage(list, ResultWrapper.SUCC, "查询成功");
		} catch (Exception e) {
			return ResultWrapper.wrapListPage(null, ResultWrapper.FAIL, "查询失败");
		}

	}

	/**
	 * 查询资讯详细
	 * 
	 * @param user
	 * @return IResultable
	 */
	@RequestMapping(value = "/detail")
	@ResponseBody
	public IResultable detail(HttpServletRequest request, Info info) {
		try {
			Map<String, Object> map = this.infoService.queryInfoDetail(info);
			return ResultWrapper4Layui.wrapMap(map, ResultWrapper4Layui.SUCC, "查询成功");
		} catch (Exception e) {
			return ResultWrapper4Layui.wrapMap(null, ResultWrapper4Layui.FAIL, "查询失败");
		}

	}
}
